<?php
$user = $data['user'];
//dump($data);


?>
<!DOCTYPE html>
<html lang="zhcn">
<head>
    <include file="Common/meta" />
    <title>LIKE - {$_ENV['site'][0]['title']}</title>
    <include file="Common/link" />
</head>
<body>
<div class="layout-header">
    <div class="container">
        <h1 class="title">LIKE</h1>
        <a class="header-back" href="/user/personCenter"><i class="icon icon-left"></i></a>
    </div>
</div>
<div class="container container-main">
    <ul class="common-tab-list nav">
        <li class="nav-item active"><a class="nav-link" href="/like/likeMe">企业LIKE</a></li>
        <li class="nav-item"><a class="nav-link" href="/like/myLike">我LIKE</a></li>
    </ul>

    <section class="box box-tab">
        <div class="box-body">
            <?php
        //dump($data);
    ?>
            <if condition="count($data['list']) eq 0">
                <div id="search-empty" class="content-empty show">
                    <div class="picture"></div>
                    <div class="no-data">还没有任何企业LIKE您，<a href="/stdproduct/listPage">去完善我的作品</div>
                </div>
            </if>
            <ul class="list like-list">
                <foreach name="data['list']" item="com">
                    <li class="list-item">
                        <img class="item-logo mylike-logo" src="{$com['logo']}">
                        <div class="item-info mylike-info">
                            <div><a class="item-name" href="/cpn/detail?id={$com['id']}" ">{$com['name']}</a>
                            </div>
                            <div class="item-desc">Like信息：{$com['like_msg']}</div>
                            <a class="item-like like-com" href="#" data-id="3"><i class="like-img"></i><div class="like-text">LIKE</div></a>
                            <div class="like-time">{$com['like_time']|strtotime|date="Y-m-d H:i",###}</div>
                        </div>
                    </li>
                </foreach>

            </ul>

        </div>

    </section>
</div>
<!-- LIKE弹框 -->
<section id="like-dialog" class="box box-like">
    <header>LIKE</header>
    <div class="box-body">
        <textarea id="like-text" placeholder="你想对这家公司说什么？" rows="4"></textarea>
        <div id="quick-box">
            <p>示例:</p>
            <ul id="quick-list" class="quick-list clear">
                <li><a href="#">我很喜欢你们公司，希望能进贵公司实习</a></li>
                <li><a href="#">我能力不错，希望能进公司锻炼</a></li>
                <li><a href="#">公司技术氛围不错，很喜欢你们公司</a></li>
            </ul>
        </div>

        <input class="login-btn cancel" type="button" value="取消">
        <input class="login-btn submit" id="like-btn" type="button" value="确定">

    </div><!-- ./box-body -->
</section>

<script>
    var page = {
        isOpen: '{$user['is_open']}',
        userType: '{$_ENV['user']['type']}',
        type: '{$data['type']}',
        keyword: '{$data['key']}',
        searchType: 0,
        searchArea: '{$data['area']}',
        searchIndustry: '{$data['indus']}'
    };
</script>
<include file="Common/script" />
<script>
    // 快速输入
    $('#quick-list').on('click', 'a', function (e) {
        e.preventDefault();
        $('#like-text').val($(this).text());
    });

    var curComId;
    //Like企业
    $(document).on('click', '.like-com', function (e) {
        e.preventDefault();
        var $this = $(this);
        curComId = $(this).data('id');

        $('#like-dialog').dialog();
    });

    $('#like-btn').on('click', function () {

        var value = $('#like-text').val();
        if (!value) {
            eui.msg('请输入内容');
            return;
        }
        $.ajax({
            url: '/user/like',
            data: {
                id: curComId,
                like_msg: value
            },
            type: 'POST',
            dataType: 'json',
            success: function (obj) {
                if (obj.code === 0) {
                    $('#like-dialog').dialog('hide');
                    eui.msg('发送成功');
                } else {
                    eui.msg(obj.msg);
                }
            },
            error: function () {
                eui.msg('系统出错');
            }
        })
    });
    $('.box-like .cancel').on('click', function() {
        $('#like-dialog').dialog('hide');
    });
    // 设置是否对外显示重要信息
    $('#modify-open').on('click', function (e) {
        e.preventDefault();

        $.ajax({
            url: '/user/hideInfoToggle',
            dataType: 'json',
            success: function (obj) {
                if (obj.code === 0) {
                    //location.reload(true);
                    if (page.isOpen === 1) {
                        page.isOpen = 0;
                        $('#open-state').text('否');
                    } else {
                        page.isOpen = 1;
                        $('#open-state').text('是');
                    }
                } else {
                    eui.msg('操作失败');
                }
            },
            error: function () {
                eui.msg('系统出错');
            }
        });
    });

</script>
</body>
</html>

